home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / test / sh2 < prev    next >
Text File  |  1990-07-23  |  5KB  |  250 lines

  1. # Shell script #2 used to test MINIX.
  2.  
  3. echo -n "Shell test  2 "
  4. rm -rf testdir
  5. mkdir testdir            # all files are created here
  6. cd testdir
  7.  
  8. cat >file <<END
  9. The time has come the walrus said to talk of many things
  10. Of shoes and ships and sealing wax of cabbages and kings
  11. Of why the sea is boiling hot and whether pigs have wings
  12. END
  13. f=file                # scratch file
  14.  
  15. cat >makefile <<END        # create a makefile
  16. all:    x.c
  17.     @cc -F x.c
  18. END
  19. cat >x.c <<END            # create a C program
  20. char s[] = {"MS-DOS: Just say no"};    /* used by strings later */
  21. main() 
  22. {
  23.   int i; 
  24.   for (i = 15; i < 18; i++) printf("%d\\n",i*i);
  25. }
  26. END
  27.  
  28. cat >answer <<END        # C program should produce these results
  29. 225
  30. 256
  31. 289
  32. END
  33.  
  34. make
  35. if test -f a.out; then : ; else echo Compilation failed; fi
  36. a.out >x
  37. if test -f x; then : ; else echo No compiler output; fi
  38. if cmp -s x answer; then : ; else echo Error in cc test 1; fi
  39.  
  40. #Test chmod
  41. echo Hi there folks >x
  42. if test -r x; then : ; else echo Error on chmod test 1; fi
  43. chmod 377 x
  44. if test -r x; then echo Error on chmod test 2; fi
  45. chmod 700 x
  46. if test -r x; then : ; else echo Error on chmod test 3; fi
  47.  
  48. #Test cut
  49. cat >x <<END            # x is a test file with 3 columns
  50. 1 white bunny
  51. 2 gray  rabbits
  52. 3 brown hares
  53. 4 black conies
  54. END
  55.  
  56. cat >answer <<END        # after cutting out cols 3-7, we get this
  57. white
  58. gray 
  59. brown
  60. black
  61. END
  62.  
  63. cut -c3-7 x >y            # extract columns 3-7
  64. if cmp -s y answer; then : ; else echo Error in cut test 1; fi
  65.  
  66. #Test dd
  67. dd if=$f of=x bs=12 count=1 2>/dev/null        # x = bytes 0-11
  68. dd if=$f of=y bs=6 count=4 skip=2 2>/dev/null    # y = bytes 11-35
  69. cat x y >z                    # z = bytes 0-35
  70. dd if=$f of=answer bs=9 count=4 2>/dev/null    # answer = bytes 0-35
  71. if cmp -s z answer; then : ; else echo Error in dd test 1; fi
  72.  
  73. #Test df            # hard to make a sensible Test here
  74. rm ?
  75. df >x
  76. if test -r x; then : ; else echo Error in df Test 1; fi
  77.  
  78. #Test du            # see df
  79. rm ?
  80. du >x
  81. if test -r x; then : ; else echo Error in du Test 1; fi
  82.  
  83. #Test od            
  84. head -1 $f |od >x        # see if od converts ascii to octal ok
  85. if chip M68000
  86. then
  87. cat >answer <<END
  88. 0000000 052150 062440 072151 066545 020150 060563 020143 067555
  89. 0000020 062440 072150 062440 073541 066162 072563 020163 060551
  90. 0000040 062040 072157 020164 060554 065440 067546 020155 060556
  91. 0000060 074440 072150 064556 063563 005000
  92. 0000071
  93. END
  94. else
  95. cat >answer <<END
  96. 0000000 064124 020145 064564 062555 064040 071541 061440 066557
  97. 0000020 020145 064164 020145 060567 071154 071565 071440 064541
  98. 0000040 020144 067564 072040 066141 020153 063157 066440 067141
  99. 0000060 020171 064164 067151 071547 000012
  100. 0000071
  101. END
  102. fi
  103.  
  104. if cmp -s x answer; then : ; else echo Error in od test 1; fi
  105.  
  106. head -1 $f |od -d >x        # see if od converts ascii to decimal ok
  107. if chip M68000
  108. then
  109. cat >answer <<END
  110. 0000000 21608 25888 29801 28005 08296 24947 08291 28525
  111. 0000020 25888 29800 25888 30561 27762 30067 08307 24937
  112. 0000040 25632 29807 08308 24940 27424 28518 08301 24942
  113. 0000060 31008 29800 26990 26483 02560
  114. 0000071
  115. END
  116. else
  117. cat >answer <<END
  118. 0000000 26708 08293 26996 25965 26656 29537 25376 28015
  119. 0000020 08293 26740 08293 24951 29292 29557 29472 26977
  120. 0000040 08292 28532 29728 27745 08299 26223 27936 28257
  121. 0000060 08313 26740 28265 29543 00010
  122. 0000071
  123. END
  124. fi
  125.  
  126. if cmp -s x answer; then : ; else echo Error in od test 2; fi
  127.  
  128. #Test paste
  129. cat >x <<END
  130. red
  131. green
  132. blue
  133. END
  134.  
  135. cat >y <<END
  136. rood
  137. groen
  138. blauw
  139. END
  140. cat >answer <<END
  141. red    rood
  142. green    groen
  143. blue    blauw
  144. END
  145.  
  146. paste x y >z
  147. if cmp -s z answer; then : ; else echo Error in paste test 1; fi
  148.  
  149. #Test prep
  150. echo >x <<END
  151. "Hi," said Carol, laughing, "How's life?"
  152. END
  153.  
  154. echo >answer <<END
  155. hi
  156. said
  157. carol
  158. laughing
  159. how's
  160. life
  161. END
  162.  
  163. if cmp -s x answer; then : ; else echo Error in prep test 1; fi
  164.  
  165. #Test printenv
  166. printenv >x
  167. if grep HOME  x >/dev/null; then : ; else echo Error in printenv test 1; fi
  168. if grep PATH  x >/dev/null; then : ; else echo Error in printenv test 2; fi
  169. if grep SHELL x >/dev/null; then : ; else echo Error in printenv test 3; fi
  170. if grep USER  x >/dev/null; then : ; else echo Error in printenv test 4; fi
  171.  
  172. #Test pwd
  173. pwd >Pwd_file
  174. cd `pwd`
  175. pwd >x
  176. if test -s Pwd_file;  then : ; else echo Error in pwd test 1; fi
  177. if cmp -s Pwd_file x; then : ; else echo Error in pwd test 2; fi
  178.  
  179. #Test strings
  180. strings a.out | grep "MS-DOS" >x
  181. cat >answer <<END
  182. MS-DOS: Just say no
  183. END
  184.  
  185. if cmp -s x answer; then : ; else echo Error in strings test 1; fi
  186.  
  187. #Test sum
  188. sum $f >x
  189. cat >answer <<END
  190. 29904     1
  191. END
  192.  
  193. if cmp -s x answer; then : ; else echo Error in sum test 1; fi
  194.  
  195. #Test tee
  196. cat $f | tee x >/dev/null
  197. if cmp -s x $f; then : ; else echo Error in tee test 1; fi
  198.  
  199. #Test true
  200. if true ; then : ; else echo Error in true test 1; fi
  201.  
  202. #Test uniq
  203. cat >x <<END
  204. 100
  205. 200
  206. 200
  207. 300
  208. END
  209.  
  210. cat >answer <<END
  211. 100
  212. 200
  213. 300
  214. END
  215.  
  216. uniq <x >y
  217. if cmp -s y answer; then : ; else echo Error in uniq test 1; fi
  218.  
  219. #Test pipelines
  220. cat >x <<END
  221. the big black dog
  222. the little white cat
  223. the big white sheep
  224. the little black cat
  225. END
  226.  
  227. cat >answer <<END
  228.    2 big
  229.    2 black
  230.    2 cat
  231.    1 dog
  232.    2 little
  233.    1 sheep
  234.    4 the
  235.    2 white
  236. END
  237.  
  238. prep x | sort | uniq -c >y1
  239. sort +1 <y1 >y
  240. if cmp -s y answer; then : ; else echo Error in pipeline test 1; fi
  241.  
  242. cat $f $f $f | sort | uniq >x
  243. sort <$f >y
  244. if cmp -s x y; then : ; else echo Error in pipeline test 2; fi
  245.  
  246. cd ..
  247. rm -rf testdir
  248.  
  249. echo ok
  250.